package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SystemDictionaryItem;
import cn.wolfcode.crm.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.crm.mapper.EmployeeMapper;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {

    @Autowired
    private SystemDictionaryItemMapper systemDictionaryItemMapper;
    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public PageInfo query(QueryObject qo) {
        //传入当前页,以及每页显示条数
        PageHelper.startPage(qo.getCurrentPage(),10,"sdi.sequence desc");
        List<SystemDictionaryItem> list = systemDictionaryItemMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void save(SystemDictionaryItem systemDictionaryItem) {
        systemDictionaryItemMapper.insert(systemDictionaryItem);
    }

    @Override
    public void update(SystemDictionaryItem systemDictionaryItem) {
        systemDictionaryItemMapper.updateByPrimaryKey(systemDictionaryItem);
    }

    @Override
    public void delete(Long id) {
        systemDictionaryItemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public SystemDictionaryItem get(Long id) {
        return systemDictionaryItemMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SystemDictionaryItem> list() {
        return systemDictionaryItemMapper.selectAll();
    }

    @Override
    public List<SystemDictionaryItem> queryBySystemDictionaryJob(String job) {
        return systemDictionaryItemMapper.queryBySystemDictionaryJob(job);
    }

    @Override
    public List<SystemDictionaryItem> queryBySystemDictionarySource(String source) {
        return systemDictionaryItemMapper.queryBySystemDictionarySource(source);
    }

    @Override
    public List<SystemDictionaryItem> queryBySystemDictionaryCommunicationMethod(String communicationMethod) {
        return systemDictionaryItemMapper.queryBySystemDictionaryCommunicationMethod(communicationMethod);
    }

    @Override
    public List<SystemDictionaryItem> queryBySystemDictionarytraceResult(String traceResult) {
        return systemDictionaryItemMapper.queryBySystemDictionarytraceResult(traceResult);
    }

    @Override
    public List<SystemDictionaryItem> queryBySystemDictionaryCourse(String course) {

        return systemDictionaryItemMapper.queryBySystemDictionaryCourse(course);
    }
}
